package com.zhou.utis.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 这是一个公用类，用来统一返回结果结构的
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    //状态码
    private Integer code;
    //信息
    private String message;
    //数据
    private Object data;

    public static Result success(){
        return new Result();
    }
    public static Result success(String msg,Object data){
        return new Result(200,msg,data);
    }
    //成功 返回数据
    public static Result success(Object data){
        return new Result(200,"成功",data);
    }
    //失败 返回空
    public static Result error(){
        return new Result(500,"失败",null);
    }
    //成功 返回成功信息
    public static Result success(String msg){
        return new Result(200,msg,null);
    }
    //失败 返回失败信息
    public static Result error(String msg){
        return new Result(500,msg,null);
    }
}
